Skip to content

chore: add realtime tool output serialization edge cases#3077

Open
Aphroq wants to merge 2 commits intoopenai:mainfrom
Aphroq:chore/realtime-serialization-tests
Open

chore: add realtime tool output serialization edge cases#3077
Aphroq wants to merge 2 commits intoopenai:mainfrom
Aphroq:chore/realtime-serialization-tests

Conversation

@Aphroq
Copy link
Copy Markdown
Contributor

@Aphroq Aphroq commented May 1, 2026

Summary

This pull request adds focused edge-case coverage for realtime tool output serialization.

Test plan

  • uv run pytest tests/realtime/test_session.py -q

Issue number

N/A

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@Aphroq Aphroq changed the title test: add realtime tool output serialization edge cases chore: add realtime tool output serialization edge cases May 1, 2026
Copy link
Copy Markdown
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding these patterns is great, but can you use parametrized testing?

@pytest.mark.parametrize(
    ("value", "expected"),
    [
        pytest.param(None, "null", id="none"),
        pytest.param(["hello", 1, True, None], json.dumps(["hello", 1, True, None]), id="list"),
        pytest.param(ToolResult(label="demo", values=[1, 2]), json.dumps({"label": "demo", "values": [1, 2]}), id="dataclass"),
        pytest.param(b"abc", "b'abc'", id="bytes"),
    ],
)
def test_serialize_tool_output_edge_cases(self, value: Any, expected: str) -> None:
    assert _serialize_tool_output(value) == expected

@seratch seratch marked this pull request as draft May 2, 2026 00:17
Aphroq added 2 commits May 2, 2026 11:27
Add focused realtime serialization coverage for _serialize_tool_output.

- serialize None as JSON null
- serialize lists as JSON arrays
- serialize dataclass instances via asdict
- fall back to string output for raw bytes
@Aphroq Aphroq force-pushed the chore/realtime-serialization-tests branch from a14a863 to 057d013 Compare May 2, 2026 12:04
@seratch seratch marked this pull request as ready for review May 2, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants